package com.pai4j.remote.user;

import com.pai4j.common.bean.PAIResponseBean;
import com.pai4j.domain.vo.response.PendingApprovalResponseVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 统一待审核Feign Client
 */
@FeignClient(value = "user-service", contextId = "pendingApprovalClient")
public interface PendingApprovalClient {

    /**
     * 查询待审核列表
     * 
     * @param approverAccount 审批人账号
     * @param approvalType 审批类型，null则查询所有类型（1=好友申请，2=加群申请）
     * @param approvalStatus 审批状态（1=待处理）
     * @return 待审核列表
     */
    @GetMapping("/user-service/pending-approval/list")
    PAIResponseBean<List<PendingApprovalResponseVO>> listPendingApprovals(
            @RequestParam("approverAccount") String approverAccount,
            @RequestParam(value = "approvalType", required = false) Integer approvalType,
            @RequestParam("approvalStatus") Integer approvalStatus);

    /**
     * 查询未读待审核列表
     * 
     * @param approverAccount 审批人账号
     * @param approvalType 审批类型，null则查询所有类型
     * @param approvalStatus 审批状态（1=待处理）
     * @return 未读待审核列表
     */
    @GetMapping("/user-service/pending-approval/unread-list")
    PAIResponseBean<List<PendingApprovalResponseVO>> listUnreadPendingApprovals(
            @RequestParam("approverAccount") String approverAccount,
            @RequestParam(value = "approvalType", required = false) Integer approvalType,
            @RequestParam("approvalStatus") Integer approvalStatus);

    /**
     * 统计未读待审核数量
     * 
     * @param approverAccount 审批人账号
     * @param approvalType 审批类型，null则统计所有类型
     * @param approvalStatus 审批状态（1=待处理）
     * @return 未读数量
     */
    @GetMapping("/user-service/pending-approval/unread-count")
    PAIResponseBean<Long> countUnreadPendingApprovals(
            @RequestParam("approverAccount") String approverAccount,
            @RequestParam(value = "approvalType", required = false) Integer approvalType,
            @RequestParam("approvalStatus") Integer approvalStatus);

    /**
     * 标记待审核为已读
     * 同时更新统一待审核表和对应的业务表（强一致性）
     * 
     * @param approverAccount 审批人账号
     * @param approvalType 审批类型，null则标记所有类型
     * @param approvalStatus 审批状态（1=待处理）
     * @return 标记数量
     */
    @PostMapping("/user-service/pending-approval/mark-read")
    PAIResponseBean<Integer> markApprovalsAsRead(
            @RequestParam("approverAccount") String approverAccount,
            @RequestParam(value = "approvalType", required = false) Integer approvalType,
            @RequestParam("approvalStatus") Integer approvalStatus);
}
